using System;
using System.Diagnostics;
using Microsoft.WowAddonStudio.FrameXml.Components.Events.ScriptManager;
using Microsoft.WowAddonStudio.FrameXml.Serialization;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Tests.Mocks
{
	public class MockFrameXmlScriptManager : IFrameXmlScriptManager
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="MockFrameXmlScriptManager"/> class.
		/// </summary>
		public MockFrameXmlScriptManager()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="MockFrameXmlScriptManager"/> class.
		/// </summary>
		/// <param name="isValid">if set to <c>true</c> [is valid].</param>
		public MockFrameXmlScriptManager(bool isValid)
		{
			IsValid = isValid;
		}

		/// <summary>
		/// Adds the script.
		/// </summary>
		/// <param name="control">The control.</param>
		/// <param name="eventName">Name of the event.</param>
		/// <param name="script">The script.</param>
		public void AddScript(FrameControl control, EventName eventName, string script)
		{
			control.ScriptContainer.Add(eventName, script);
		}

		/// <summary>
		/// Removes the script.
		/// </summary>
		/// <param name="control">The control.</param>
		/// <param name="eventName">Name of the event.</param>
		public void RemoveScript(FrameControl control, EventName eventName)
		{
			control.ScriptContainer.Remove(eventName);
		}

		/// <summary>
		/// Creates the show function.
		/// </summary>
		/// <param name="eventHandlerCode">Name of the event handler.</param>
		public void CreateOrShowFunction(string eventHandlerCode)
		{
			Trace.WriteLine(String.Format("CreateFunction called: {0}", eventHandlerCode));
		}

		/// <summary>
		/// Gets a value indicating whether this instance is valid.
		/// </summary>
		/// <value><c>true</c> if this instance is valid; otherwise, <c>false</c>.</value>
		public bool IsValid { get; private set; }

		/// <summary>
		/// Initializes this instance.
		/// </summary>
		public void Initialize()
		{
			IsValid = false;
		}
	}
}